package com.cq.androidtools.jetpack.startup

import android.content.Context
import android.util.Log
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking

/**
 * 作者: CQ
 * 日期: 2021-05-31
 * 说明:
 */
class Sdk2 {

    companion object {
        val TAG = "SDK2"
        lateinit var sApplicationContext: Context

        @Volatile
        var sInstance: Sdk2? = null

        fun init(applicationContext: Context) {
            Log.e(Sdk1.TAG, "Sdk2 is initialize")
            runBlocking {
                delay(1000)
            }
            sApplicationContext = applicationContext
            Log.e(TAG, "Sdk2 is initialized = " + System.currentTimeMillis())
        }

        fun getInstance(): Sdk2 {
            return sInstance ?: synchronized(this) {
                sInstance ?: Sdk2()
            }
        }


    }

    private fun printApplicationName(){
        Log.e(TAG, sApplicationContext.packageName)
    }

}